﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace UISockets
{
    class Program
    {
        static void Main(string[] args)
        {
            CTILinker ctiLink = new CTILinker();
            ctiLink.SetCTIAddress("127.0.0.1", 6853);
            ctiLink.Connect();
            ctiLink.StartWaitForData();

            //测试发送请求 开始

            ctiLink.SendRequestGetDriverInfoList();
            Thread.Sleep(500);

            ctiLink.SendRequestStartLog();
            Thread.Sleep(500);
            ctiLink.SendRequestStopLog();
            Thread.Sleep(500);
            ctiLink.SendRequestStartLog();
            Thread.Sleep(500);
            //ctiLink.SendRequestStopLog();
            Thread.Sleep(500);


            ctiLink.SendRequestOpenLineInfo();
            Thread.Sleep(500);
            ctiLink.SendRequestCloseLineInfo();
            Thread.Sleep(500);
            ctiLink.SendRequestOpenLineInfo();
            Thread.Sleep(500);
            //ctiLink.SendRequestCloseLineInfo();
            Thread.Sleep(500);


//             ctiLink.SendRequestDriverInfoByDriverName("not exists.");
//             Thread.Sleep(500);
//             ctiLink.SendRequestDriverInfoByDriverName("HWRMS-1");
//             Thread.Sleep(500);
// 
// 
// 
//             ctiLink.SendRequestDriverInfoByDLLName("not exists.");
//             Thread.Sleep(500);
//             ctiLink.SendRequestDriverInfoByDLLName("HwRmsDriver.dll");
//             Thread.Sleep(500);
//             ctiLink.SendRequestDriverInfoByDLLName("HwRmsDriver-2.dll");
//             Thread.Sleep(500);
// 
// 
//             ctiLink.SendRequestAddDriver("HWRMS-2", "HwRmsDriver-2.dll", "DriverName=HWRMS-1,HostMain=127.0.0.1,HostBackup=0.0.0.0,Port=7777");
//             Thread.Sleep(500);
//             ctiLink.SendRequestAddDriver("HWRMS-3", "HwRmsDriver-2.dll", "test");
//             Thread.Sleep(500);
// 
// 
//             ctiLink.SendRequestUpdateDriver("HWRMS-2", "HwRmsDriver-2.dll", "test222222222");
//             Thread.Sleep(500);
//             ctiLink.SendRequestUpdateDriver("HWRMS-4", "HwRmsDriver-2.dll", "test222222222");
//             Thread.Sleep(500);
// 
//             ctiLink.SendRequestDeleteDriver("HWRMS-2");
//             Thread.Sleep(500);
//             ctiLink.SendRequestDeleteDriver("HWRMS-5");
//             Thread.Sleep(500);
// 
//             ctiLink.SendRequestStopDriver("HWRMS-2");
//             Thread.Sleep(500);
//             ctiLink.SendRequestStartDriver("HWRMS-2");
//             Thread.Sleep(500);
// 

            //启动与停止Driver只能在收到回复之后做下一步处理
            //停止Driver在Frame内部是一个异步的操作，收到UI的停止命令之后，并不会立刻停止driver
            ctiLink.SendRequestStartDriver("HWRMS-1");
            Thread.Sleep(500);
            ctiLink.SendRequestStopDriver("HWRMS-1");
            Thread.Sleep(3000);
            ctiLink.SendRequestStartDriver("HWRMS-1");
            Thread.Sleep(500);

            //测试发送请求 结束

            Console.Read();
            ctiLink.Close();
        }
    }
}
